package com.itheima.controller;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.pojo.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {
    @Reference
    private SetmealService setmealService;

    @RequestMapping("/getSetmeal")
    public Result getSetmeal() {
        JSONArray setmeals = setmealService.getSetmeal();
        return Result.success("", setmeals);
    }

    @RequestMapping("/findById")
    public Result findById(int id) {
        JSONObject setmeal = setmealService.findById(id);
        return Result.success("", setmeal);
    }
    @RequestMapping("/findDetailById")
    public Result findDetailById(int id) {
        Setmeal setmeal = setmealService.findDetailById(id);
        return Result.success("", setmeal);
    }

}
